//package com.sky.trade.task;
//
//import com.alibaba.fastjson.JSON;
//import com.sky.trade.websocket.WebSocketServer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.HashMap;
//
//@Component
//public class WebSocketTask {
//    @Autowired
//    private WebSocketServer webSocketServer;
//
//    /**
//     * 通过WebSocket每隔100秒向客户端发送消息
//     */
//    @Scheduled(cron = "0/100 * * * * ?")
//    public void sendMessageToClient() {
//        final String str = "这是来自服务端的消息：" + DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now());
//        final HashMap<Object, Object> map = new HashMap<>();
//        map.put("content", str);
//        webSocketServer.sendToAllClient(JSON.toJSONString(map));
//    }
//}
